package com.situ.javase.week2.day4;

import java.security.Key;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map.Entry;
import java.util.Set;

import org.junit.Test;

import com.situ.javase.day5.Student;

public class CollectionDemo {
	
@Test
public void test1() {
	ArrayList<Student> list = new ArrayList<>();
	   Student student1 = new Student(1, "zhangsan1", 20, "Java");
	   Student student2 = new Student(2, "zhangsan2", 20, "Java");
	   Student student3 = new Student(3, "zhangsan3", 20, "Java");
	   list.add(student1);
	   list.add(student2);
	   list.add(student3);
	   list.add(student3);
	   list.add(student3);
	   for (Student student : list) {
		     System.out.println(student);
		   }
	   System.out.println("---------");
	   
	   
	//Set<Student> set = new HashSet<>();
	HashSet<Student> set = new HashSet<Student>();
		set.add(student1);
		set.add(student2);
		set.add(student3);
		set.add(student3);
		set.add(student3);
		for (Student student : set) {
			System.out.println(student);
}
}

@Test
public void test2() {
		   // CN     中华人民共和国
		   // US     美利坚合众国
		   // key    value
		   HashMap<String, String> map = new HashMap<>();
		   map.put("CN", "中华人民共和国");
		   map.put("US", "美利坚合众国");
		   //根据key，找到这个key对应的这个值value
		   String value1 = map.get("CN");
		   System.out.println(value1);
		   System.out.println("------------");
		   
		   Set<Entry<String, String>> entrySet = map.entrySet();
		   for (Entry<String, String> entry : entrySet) {
			String key = entry.getKey();
			String value = entry.getValue();
			System.out.println("key:"+ key + ",Value::" + value);
		}
		   System.out.println("-------------");
		   Set<String> keySet = map.keySet();
		   for (String key : keySet) {
			String value = map.get(key);
			System.out.println("key:"+ key + ",Value::" + value);
		}
	}
}